using System;
using System.Threading.Tasks;
using SheLife.Domain.Entities;

namespace SheLife.Domain.Interfaces.Repositories
{
    /// <summary>
    /// 系统通知模板仓储接口
    /// </summary>
    public interface ISystemNotificationTemplateRepository : IRepository<SystemNotificationTemplate>
    {
        /// <summary>
        /// 根据模板编码获取模板
        /// </summary>
        /// <param name="code">模板编码</param>
        /// <returns>模板</returns>
        Task<SystemNotificationTemplate> GetByCodeAsync(string code);

        /// <summary>
        /// 根据模板类型获取模板列表
        /// </summary>
        /// <param name="templateType">模板类型</param>
        /// <returns>模板列表</returns>
        Task<IEnumerable<SystemNotificationTemplate>> GetByTemplateTypeAsync(string templateType);

        /// <summary>
        /// 根据业务模块获取模板列表
        /// </summary>
        /// <param name="businessModule">业务模块</param>
        /// <returns>模板列表</returns>
        Task<IEnumerable<SystemNotificationTemplate>> GetByBusinessModuleAsync(string businessModule);

        /// <summary>
        /// 检查模板编码是否存在
        /// </summary>
        /// <param name="code">模板编码</param>
        /// <returns>是否存在</returns>
        Task<bool> CheckTemplateCodeExistsAsync(string code);

        /// <summary>
        /// 获取模板列表（分页）
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="templateType">模板类型</param>
        /// <param name="businessModule">业务模块</param>
        /// <param name="keyword">关键词</param>
        /// <returns>模板列表</returns>
        Task<(IEnumerable<SystemNotificationTemplate> Items, int TotalCount)> GetNotificationTemplatesPagedAsync(
            int pageIndex, 
            int pageSize, 
            string templateType = null, 
            string businessModule = null, 
            string keyword = null);

        /// <summary>
        /// 启用模板
        /// </summary>
        /// <param name="templateId">模板ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> EnableTemplateAsync(Guid templateId, Guid operatorId);

        /// <summary>
        /// 禁用模板
        /// </summary>
        /// <param name="templateId">模板ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> DisableTemplateAsync(Guid templateId, Guid operatorId);

        /// <summary>
        /// 刷新模板缓存
        /// </summary>
        /// <returns>是否成功</returns>
        Task<bool> RefreshTemplateCacheAsync();
    }
}